package com.wenbing.miio.core;

import com.wenbing.miio.core.exception.NetworkLayerException;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * @author wen bing
 * @projectName: miio
 * @package: core.ps
 * @className: PService
 * @date 2024/09/19 10:48
 **/
public interface NetworkLayer {

    /**
     * 入栈方向
     * @return
     */
    void inbound(NetworkLayerContext parentContext, ByteBuffer packingData) throws IOException, NetworkLayerException;

    /**
     * 出栈方向
     * @return
     */
    void outbound(NetworkLayerContext context, ByteBuffer unpackingData) throws IOException, NetworkLayerException;

    /**
     *
     * @return
     */
    NetworkStack.NetworkLayerNode getNetworkLayerNode();

    /**
     * 校验NetworkLayer是否有效
     * @param layer
     * @return
     */
    static boolean valid(NetworkLayer layer) {
        return layer != null;
    }
}
